//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// 

import inet.networklayer.autorouting.FlatNetworkConfigurator;

network Scenario
{
	parameters:
		int n_isps;
		int n_peers;
		int n_cdns;

	types:
		channel Low extends ned.DatarateChannel {
			volatile double datarate_inc = normal(0Mbps,0.5Mbps) @unit(Mbps);
			volatile double delay_inc = normal(0ms,10ms) @unit(ms);
			datarate = 5Mbps+this.datarate_inc;
			delay = 50ms+this.delay_inc;
			ber = 0;
			per = 0;
			@display("ls=red,1");
		}
		
		channel Average extends ned.DatarateChannel {
			volatile double datarate_inc = normal(0Mbps,1Mbps) @unit(Mbps);
			volatile double delay_inc = normal(0ms,10ms) @unit(ms);
			datarate = 10Mbps+this.datarate_inc;
			delay = 50ms+this.delay_inc;
			ber = 0;
			per = 0;
			@display("ls=yellow,1");
		}
		
		channel Dedicated extends ned.DatarateChannel {
			volatile double datarate_inc = normal(0Mbps,5Mbps) @unit(Mbps);
			volatile double delay_inc = normal(0ms,10ms) @unit(ms);
			datarate = 50Mbps+this.datarate_inc;
			delay = 50ms+this.delay_inc;
			ber = 0;
			per = 0;
			@display("ls=blue,2");
		}

		channel High extends ned.DatarateChannel {
			volatile double datarate_inc = normal(0Gbps,0.1Gbps) @unit(Gbps);
			volatile double delay_inc = normal(0ms,20ms) @unit(ms);
			datarate = 1Gbps + this.datarate_inc;
			delay = 150ms+this.delay_inc;
			ber = 0;
			per = 0;
			@display("ls=green,2");
		}

	submodules:
		//isp[n_isps]: ISP;
		risp[n_isps]: RealISP;
		peer[n_peers]: Peer;
		tracker: Tracker;
		cdn[n_cdns]: CDN;

		configurator: FlatNetworkConfigurator;

	
	connections allowunconnected:
	//connections:
	
		//tracker.pppg++ <--> Average <--> isp[intuniform(0,n_isps-1)].pppg++;
		tracker.pppg++ <--> Average <--> risp[intuniform(0,n_isps-1)].ext++;
	
		for i=0..n_isps-2, for j=i+1..n_isps-1 {
			//ISP
			//isp[i].ethg++ <--> High <--> isp[j].ethg++;
			//isp[i].ethg++ <--> {ber=0;per = 0;} <--> isp[j].ethg++;
			//isp[i].pppg++ <--> High <--> isp[j].pppg++;
			//RealISP
			risp[i].ext++ <--> High <--> risp[j].ext++;
		}

		for i=0..n_peers-1 {
			//ISP
			//peer[i].pppg++ <--> Low <--> isp[intuniform(0,n_isps-1)].pppg++;
			//RealISP
			peer[i].pppg++ <--> Low <--> risp[intuniform(0,n_isps-1)].ext++;
		}
		
		for i=0..n_cdns-1 {
			//ISP
			//cdn[i].pppg++ <--> Dedicated <--> isp[intuniform(0,n_isps-1)].pppg++;
			//RealISP
			cdn[i].pppg++ <--> Low <--> risp[intuniform(0,n_isps-1)].ext++;
		}
		
}
